package wangjg.android;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

public class BuddyListActivity extends BasicActivity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.buddy_list);
        this.init();
    }
    
    private void init(){
		LinearLayout ll = (LinearLayout) this.findViewById(R.id.buddy_list);
		for(int i=0;i<2;i++){
			this.addBuddy(ll, i);
		}
    }
    
    private void addBuddy(ViewGroup vg, Object buddy){
		View view = LayoutInflater.from(this).inflate(R.layout.contact_item,null);
		TextView text = (TextView) view.findViewById(R.id.nickname_tv);
		text.setText("user-"+buddy);
		vg.addView(view);
		view.setOnClickListener(on_buddy_click);
    }
    
    private void onBuddyClick(){
    	startActivity(new Intent(BuddyListActivity.this, ChatActivity.class));
    }
    
	OnClickListener on_buddy_click=new OnClickListener(){
		public void onClick(View v) {
			onBuddyClick();
		}  
    };
}
